home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / v cisle / htttrack / httrack-3.41-3.exe / {app} / src / htsopt.h < prev    next >
C/C++ Source or Header  |  2007-02-03  |  14KB  |  414 lines

  1. /* ------------------------------------------------------------ */
  2. /*
  3. HTTrack Website Copier, Offline Browser for Windows and Unix
  4. Copyright (C) Xavier Roche and other contributors
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20.  
  21. Important notes:
  22.  
  23. - We hereby ask people using this source NOT to use it in purpose of grabbing
  24. emails addresses, or collecting any other private information on persons.
  25. This would disgrace our work, and spoil the many hours we spent on it.
  26.  
  27.  
  28. Please visit our Website: http://www.httrack.com
  29. */
  30.  
  31.  
  32. /* ------------------------------------------------------------ */
  33. /* File: HTTrack parameters block                               */
  34. /*       Called by httrack.h and some other files               */
  35. /* Author: Xavier Roche                                         */
  36. /* ------------------------------------------------------------ */
  37.  
  38.  
  39. #ifndef HTTRACK_DEFOPT
  40. #define HTTRACK_DEFOPT
  41.  
  42. #include <stdio.h>
  43. #include "htsglobal.h"
  44.  
  45. /* Forward definitions */
  46. #ifndef HTS_DEF_FWSTRUCT_t_hts_htmlcheck_callbacks
  47. #define HTS_DEF_FWSTRUCT_t_hts_htmlcheck_callbacks
  48. typedef struct t_hts_htmlcheck_callbacks t_hts_htmlcheck_callbacks;
  49. #endif
  50. #ifndef HTS_DEF_FWSTRUCT_t_dnscache
  51. #define HTS_DEF_FWSTRUCT_t_dnscache
  52. typedef struct t_dnscache t_dnscache;
  53. #endif
  54. #ifndef HTS_DEF_FWSTRUCT_hash_struct
  55. #define HTS_DEF_FWSTRUCT_hash_struct
  56. typedef struct hash_struct hash_struct;
  57. #endif
  58. #ifndef HTS_DEF_FWSTRUCT_robots_wizard
  59. #define HTS_DEF_FWSTRUCT_robots_wizard
  60. typedef struct robots_wizard robots_wizard;
  61. #endif
  62. #ifndef HTS_DEF_FWSTRUCT_t_cookie
  63. #define HTS_DEF_FWSTRUCT_t_cookie
  64. typedef struct t_cookie t_cookie;
  65. #endif
  66.  
  67. /** Forward definitions **/
  68. #ifndef HTS_DEF_FWSTRUCT_String
  69. #define HTS_DEF_FWSTRUCT_String
  70. typedef struct String String;
  71. #endif
  72. #ifndef HTS_DEF_STRUCT_String
  73. #define HTS_DEF_STRUCT_String
  74. struct String {
  75.   char* buffer_;
  76.   size_t length_;
  77.   size_t capacity_;
  78. };
  79. #endif
  80.  
  81. /* Defines */
  82. #define CATBUFF_SIZE (STRING_SIZE*2*2)
  83. #define STRING_SIZE 2048
  84.  
  85. /* Proxy structure */
  86. #ifndef HTS_DEF_FWSTRUCT_t_proxy
  87. #define HTS_DEF_FWSTRUCT_t_proxy
  88. typedef struct t_proxy t_proxy;
  89. #endif
  90. struct t_proxy {
  91.   int active;
  92.   String name;
  93.   int port;
  94.   String bindhost;   // bind this host
  95. }; 
  96.  
  97. /* Structure utile pour copier en bloc les paramΦtres */
  98. #ifndef HTS_DEF_FWSTRUCT_htsfilters
  99. #define HTS_DEF_FWSTRUCT_htsfilters
  100. typedef struct htsfilters htsfilters;
  101. #endif
  102. struct htsfilters {
  103.   char***  filters;
  104.   int*     filptr;
  105.   //int*    filter_max;
  106. };
  107.  
  108. /* User callbacks chain */
  109. typedef int (*htscallbacksfncptr)(void);
  110. typedef struct htscallbacks htscallbacks;
  111. struct htscallbacks {
  112.   void* moduleHandle;
  113.   htscallbacksfncptr exitFnc;
  114.   htscallbacks * next;
  115. };
  116.  
  117. /* filenote() internal file structure */
  118. #ifndef HTS_DEF_FWSTRUCT_filenote_strc
  119. #define HTS_DEF_FWSTRUCT_filenote_strc
  120. typedef struct filenote_strc filenote_strc;
  121. #endif
  122. struct filenote_strc {
  123.   FILE* lst;
  124.   char path[STRING_SIZE*2];
  125. };
  126.  
  127. /* concat() functions */
  128. #ifndef HTS_DEF_FWSTRUCT_concat_strc
  129. #define HTS_DEF_FWSTRUCT_concat_strc
  130. typedef struct concat_strc concat_strc;
  131. #endif
  132. struct concat_strc {
  133.   int index;
  134.   char buff[16][STRING_SIZE*2*2];
  135. };
  136.  
  137. /* int2 functions */
  138. #ifndef HTS_DEF_FWSTRUCT_strc_int2bytes2
  139. #define HTS_DEF_FWSTRUCT_strc_int2bytes2
  140. typedef struct strc_int2bytes2 strc_int2bytes2;
  141. #endif
  142. struct strc_int2bytes2 {
  143.     char catbuff[CATBUFF_SIZE];
  144.   char buff1[256];
  145.   char buff2[32];
  146.   char* buffadr[2];
  147. };
  148.  
  149. /* cmd callback */
  150. #ifndef HTS_DEF_FWSTRUCT_usercommand_strc
  151. #define HTS_DEF_FWSTRUCT_usercommand_strc
  152. typedef struct usercommand_strc usercommand_strc;
  153. #endif
  154. struct usercommand_strc {
  155.   int exe;
  156.   char cmd[2048];
  157. };
  158.  
  159. /* error logging */
  160. #ifndef HTS_DEF_FWSTRUCT_fspc_strc
  161. #define HTS_DEF_FWSTRUCT_fspc_strc
  162. typedef struct fspc_strc fspc_strc;
  163. #endif
  164. struct fspc_strc {
  165.   int error;
  166.   int warning;
  167.   int info;
  168. };
  169.  
  170. /* Structure Θtat du miroir */
  171. #ifndef HTS_DEF_FWSTRUCT_htsoptstatecancel
  172. #define HTS_DEF_FWSTRUCT_htsoptstatecancel
  173. typedef struct htsoptstatecancel htsoptstatecancel;
  174. #endif
  175. struct htsoptstatecancel {
  176.   char *url;
  177.   htsoptstatecancel *next;
  178. };
  179.  
  180. /* Mutexes */
  181. #ifndef HTS_DEF_FWSTRUCT_htsmutex_s
  182. #define HTS_DEF_FWSTRUCT_htsmutex_s
  183. typedef struct htsmutex_s htsmutex_s, *htsmutex;
  184. #endif
  185.  
  186. /* Hashtables */
  187. #ifndef HTS_DEF_FWSTRUCT_struct_inthash
  188. #define HTS_DEF_FWSTRUCT_struct_inthash
  189. typedef struct struct_inthash struct_inthash, *inthash;
  190. #endif
  191.  
  192. /* Structure Θtat du miroir */
  193. #ifndef HTS_DEF_FWSTRUCT_htsoptstate
  194. #define HTS_DEF_FWSTRUCT_htsoptstate
  195. typedef struct htsoptstate htsoptstate;
  196. #endif
  197. struct htsoptstate {
  198.   htsmutex lock;    /* 3.41 */
  199.   /* */
  200.   int stop;
  201.   int exit_xh;
  202.   int back_add_stats;
  203.   /* */
  204.   int mimehtml_created;
  205.   String mimemid;
  206.   FILE* mimefp;
  207.   int delayedId;
  208.   /* */
  209.     filenote_strc strc;
  210.     /* Functions context (avoir thread variables!) */
  211.   htscallbacks callbacks;
  212.     concat_strc concat;
  213.     usercommand_strc usercmd;
  214.     fspc_strc fspc;
  215.     char *userhttptype;
  216.     int verif_backblue_done;
  217.     int verif_external_status;
  218.     t_dnscache *dns_cache;
  219.     /* HTML parsing state */
  220.     char _hts_errmsg[1024];
  221.     int _hts_in_html_parsing;
  222.     int _hts_in_html_done;
  223.     int _hts_in_html_poll;
  224.     int _hts_setpause;
  225.     char** _hts_addurl;
  226.   int _hts_cancel;
  227.   htsoptstatecancel *cancel;            /* 3.41 */
  228.     char HTbuff[2048];
  229.   unsigned int debug_state;
  230.   unsigned int tmpnameid;               /* 3.41 */
  231. };
  232.  
  233. /* Library handles */
  234. #ifndef HTS_DEF_FWSTRUCT_htslibhandles
  235. #define HTS_DEF_FWSTRUCT_htslibhandles
  236. typedef struct htslibhandles htslibhandles;
  237. #endif
  238. #ifndef HTS_DEF_FWSTRUCT_htslibhandle
  239. #define HTS_DEF_FWSTRUCT_htslibhandle
  240. typedef struct htslibhandle htslibhandle;
  241. #endif
  242. struct htslibhandle {
  243.   char *moduleName;
  244.   void *handle;
  245. };
  246. struct htslibhandles {
  247.   int count;
  248.   htslibhandle *handles;
  249. };
  250.  
  251. /* Javascript parser flags */
  252. typedef enum htsparsejava_flags {
  253.   HTSPARSE_NONE = 0,           // don't parse
  254.   HTSPARSE_DEFAULT = 1,        // parse default (all)
  255.   HTSPARSE_NO_CLASS = 2,       // don't parse .java
  256.   HTSPARSE_NO_JAVASCRIPT = 4,  // don't parse .js
  257.   HTSPARSE_NO_AGGRESSIVE = 8   // don't aggressively parse .js or .java
  258. } htsparsejava_flags;
  259.  
  260. // paramΦtres httrack (options)
  261. #ifndef HTS_DEF_FWSTRUCT_httrackp
  262. #define HTS_DEF_FWSTRUCT_httrackp
  263. typedef struct httrackp httrackp;
  264. #endif
  265. struct httrackp {
  266.   size_t size_httrackp; // size of this structure
  267.   /* */
  268.   int wizard;       // wizard aucun/grand/petit
  269.   int flush;        // fflush sur les fichiers log
  270.   int travel;       // type de dΘplacements (same domain etc)
  271.   int seeker;       // up & down
  272.   int depth;        // nombre de niveaux de rΘcursion
  273.   int extdepth;     // nombre de niveaux de rΘcursion α l'ΘxtΘrieur
  274.   int urlmode;      // liens relatifs etc   
  275.   int debug;        // mode dΘbug log
  276.   int getmode;      // sauver html, images..
  277.   FILE* log;        // fichier log
  278.   FILE* errlog;     // et erreur
  279.   LLint maxsite;        // taille max site
  280.   LLint maxfile_nonhtml; // taille max non html
  281.   LLint maxfile_html;   // taille max html
  282.   int maxsoc;           // nbre sockets
  283.   LLint fragment;       // fragmentation d'un site
  284.   int nearlink;         // prendre les images/data proche d'une page mais α l'extΘrieur
  285.   int makeindex;        // faire un index
  286.   int kindex;           // et un index 'keyword'
  287.   int delete_old;       // effacer anciens fichiers
  288.   int timeout;          // nombre de secondes de timeout
  289.   int rateout;          // nombre d'octets minium pour le transfert
  290.   int maxtime;          // temps max en secondes
  291.   int maxrate;          // taux de transfert max
  292.   int mms_maxtime;      // max duration of a mms file
  293.   float maxconn;        // nombre max de connexions/s
  294.   int waittime;         // dΘmarrage programmΘ
  295.   int cache;            // gΘnΘration d'un cache
  296.   //int aff_progress;     // barre de progression
  297.   int shell;            // gestion d'un shell par pipe stdin/stdout
  298.   t_proxy proxy;        // configuration du proxy
  299.   int savename_83;      // conversion 8-3 pour les noms de fichiers
  300.   int savename_type;    // type de noms: structure originale/html-images en un seul niveau
  301.   String savename_userdef;  // structure userdef (ex: %h%p/%n%q.%t)
  302.   int savename_delayed; // delayed type check
  303.   int delayed_cached;   // delayed type check can be cached to speedup updates
  304.   int mimehtml;         // MIME-html
  305.   int user_agent_send;  // user agent (ex: httrack/1.0 [sun])
  306.   String user_agent;    //
  307.   String referer;       // referer 
  308.   String from;          // from
  309.   String path_log;      // chemin pour cache et log
  310.   String path_html;     // chemin pour miroir
  311.   String path_bin;      // chemin pour templates
  312.   int retry;            // nombre d'essais supplΘmentaires en cas d'Θchec
  313.   int makestat;         // mettre α jour un fichier log de statistiques de transfert
  314.   int maketrack;        // mettre α jour un fichier log de statistiques d'opΘrations
  315.   int parsejava;        // parsing des classes java pour rΘcupΘrer les class, gif & cie ; see htsparsejava_flags
  316.   int hostcontrol;      // abandon d'un host trop lent etc.
  317.   int errpage;          // gΘnΘrer une page d'erreur en cas de 404 etc.
  318.   int check_type;       // si type inconnu (cgi,asp,/) alors tester lien (et gΘrer moved Θventuellement)
  319.   int all_in_cache;     // tout mettre en cache!
  320.   int robots;           // traitement des robots
  321.   int external;         // pages externes->pages d'erreur
  322.   int passprivacy;      // pas de mot de pass dans les liens externes?
  323.   int includequery;     // include la query-string
  324.   int mirror_first_page; // miroir des liens
  325.   String sys_com;       // commande systΦme
  326.   int sys_com_exec;     // executer commande 
  327.   int accept_cookie;    // gestion des cookies
  328.   t_cookie* cookie;
  329.   int http10;           // forcer http 1.0
  330.   int nokeepalive;      // pas de keep-alive
  331.   int nocompression;    // pas de compression
  332.   int sizehack;         // forcer rΘponse "mis α jour" si taille identique
  333.   int urlhack;          // force "url normalization" to avoid loops
  334.   int tolerant;         // accepter content-length incorrect
  335.   int parseall;         // essayer de tout parser (tags inconnus contenant des liens, par exemple)
  336.   int parsedebug;       // dΘbugger parser (debug!)
  337.   int norecatch;        // ne pas reprendre les fichiers effacΘs localement par l'utilisateur
  338.   int verbosedisplay;   // animation textuelle
  339.   String footer;        // ligne d'infos
  340.   int maxcache;         // maximum en mΘmoire au niveau du cache (backing)
  341.   //int maxcache_anticipate; // maximum de liens α anticiper (majorant)
  342.   int ftp_proxy;        // proxy http pour ftp
  343.   String filelist;      // fichier liste URL α inclure
  344.   String urllist;       // fichier liste de filtres α inclure
  345.   htsfilters filters;   // contient les pointeurs pour les filtres
  346.   hash_struct* hash;    // hash structure
  347.   robots_wizard* robotsptr;         // robots ptr
  348.   String lang_iso;      // en, fr ..
  349.   String mimedefs;      // ext1=mimetype1\next2=mimetype2..
  350.   String mod_blacklist; // (3.41)
  351.   //
  352.   int maxlink;          // nombre max de liens
  353.   int maxfilter;        // nombre max de filtres
  354.   //
  355.   char* exec;           // adresse du nom de l'Θxecutable
  356.   //
  357.   int quiet;            // poser des questions autres que wizard?
  358.   int keyboard;         // vΘrifier stdin
  359.   int bypass_limits;    // bypass built-in limits
  360.   //
  361.   int is_update;        // c'est une update (afficher "File updated...")
  362.   int dir_topindex;     // reconstruire top index par la suite
  363.   //
  364.   // callbacks
  365.     t_hts_htmlcheck_callbacks *callbacks_fun;
  366.   // store library handles
  367.   htslibhandles libHandles;
  368.   //
  369.   htsoptstate state;    // state
  370. };
  371.  
  372. // stats for httrack
  373. #ifndef HTS_DEF_FWSTRUCT_hts_stat_struct
  374. #define HTS_DEF_FWSTRUCT_hts_stat_struct
  375. typedef struct hts_stat_struct hts_stat_struct;
  376. #endif
  377. struct hts_stat_struct {
  378.   LLint HTS_TOTAL_RECV;      // flux entrant reτu
  379.   LLint stat_bytes;          // octets Θcrits sur disque
  380.   // int HTS_TOTAL_RECV_STATE;  // status: 0 tout va bien 1: ralentir un peu 2: ralentir 3: beaucoup
  381.   TStamp stat_timestart;     // dΘpart
  382.   //
  383.   LLint total_packed;        // flux entrant compressΘ reτu
  384.   LLint total_unpacked;      // flux entrant compressΘ reτu
  385.   int   total_packedfiles;   // fichiers compressΘs
  386.   //
  387.   TStamp istat_timestart[2];   // dΘpart pour calcul instantannΘ
  388.   LLint  istat_bytes[2];       // calcul pour instantannΘ
  389.   TStamp istat_reference01;    // top dΘpart donnΘ par #0 α #1
  390.   int    istat_idlasttimer;    // id du timer qui a rΘcemment donnΘ une stat
  391.   //
  392.   int stat_files;            // nombre de fichiers Θcrits
  393.   int stat_updated_files;    // nombre de fichiers mis α jour
  394.   int stat_background;       // nombre de fichiers Θcrits en arriΦre plan
  395.   //
  396.   int stat_nrequests;        // nombre de requΩtes sur socket
  397.   int stat_sockid;           // nombre de sockets allouΘes au total
  398.   int stat_nsocket;          // nombre de sockets
  399.   int stat_errors;           // nombre d'erreurs
  400.   int stat_errors_front;     // idem, mais au tout premier niveau
  401.   int stat_warnings;         // '' warnings
  402.   int stat_infos;            // '' infos
  403.   int nbk;                   // fichiers anticipΘs en arriΦre plan et terminΘs
  404.   LLint nb;                  // donnΘes transfΘrΘes actuellement (estimation)
  405.   //
  406.   LLint rate;
  407.   //
  408.   TStamp last_connect;      // last connect() call
  409.   TStamp last_request;      // last request issued
  410. };
  411.  
  412. #endif
  413.  
  414.